using MicroMsg.Manager;
using MicroMsg.Plugin.FaceBook;
using MicroMsg.Resource.@string;
using MicroMsg.Storage;
using MicroMsg.UI.Page;
using MicroMsg.UI.Util;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.UserContrl
{
	public class AccountSettingView : BasePage
	{
		internal Grid LayoutRoot;
		internal Grid ContentPanel;
		internal StackPanel layoutAlias;
		internal TextBlock txtAlias;
		internal ClickableLayout layoutMMName;
		internal TextBlock txtMMName;
		internal TextBlock txtQQNum;
		internal TextBlock txtPhoneNum;
		internal TextBlock txtEmail;
		internal ClickableLayout FaceBookArea;
		internal TextBlock txtFaceBook;
		private bool _contentLoaded;
		public AccountSettingView()
		{
			this.InitializeComponent();
		}
		protected override void OnPageIn(object[] object_0)
		{
			this.refreshView();
		}
		protected override void OnPageBack()
		{
			this.refreshView();
		}
		private void refreshView()
		{
			this.txtMMName.set_Text(this.trimToEmpty(AccountMgr.strUsrName));
			string text = this.trimToEmpty(AccountMgr.getCurAccount().strAlias);
			this.txtAlias.set_Text(text);
			if (text == "")
			{
				this.layoutAlias.set_Visibility(1);
				this.layoutMMName.set_Visibility(0);
			}
			else
			{
				this.layoutAlias.set_Visibility(0);
				this.layoutMMName.set_Visibility(1);
			}
			string text2 = (AccountMgr.nBindQQ > 0u) ? string.Concat(AccountMgr.nBindQQ) : strings.Set_Account_NotBind;
			this.txtQQNum.set_Text(text2);
			string text3 = this.trimToDefault(AccountMgr.strBindMobile, "");
			string text4;
			if (!ToolFunction.checkIsPhoneNumber(AccountMgr.strBindMobile))
			{
				text4 = strings.Set_Account_NotBind;
			}
			else
			{
				if (!AccountMgr.MobileVerify)
				{
					text4 = text3 + strings.Set_Account_NotVerrify;
				}
				else
				{
					text4 = text3;
				}
			}
			this.txtPhoneNum.set_Text(text4);
			string faceBookName = this.GetFaceBookName();
			if (string.IsNullOrEmpty(faceBookName))
			{
				this.txtFaceBook.set_Text(strings.Set_Account_NotBind);
			}
			else
			{
				this.txtFaceBook.set_Text(faceBookName);
			}
			if (FaceBookMgr.IsChina())
			{
				this.FaceBookArea.set_Visibility(1);
			}
		}
		private void changeTextColor(TextBlock textBlock)
		{
			if (textBlock != null)
			{
				if (strings.Set_Account_NotBind.Equals(textBlock.get_Text()))
				{
					textBlock.set_Foreground(R.theme.COMMON_BRUSH);
					return;
				}
				textBlock.set_Foreground(R.theme.COMMON_2EDTITLE_NORMAL_WORD__BRUSH);
			}
		}
		private string trimToEmpty(string string_0)
		{
			if (string_0 != null)
			{
				return string_0.Trim();
			}
			return "";
		}
		private string trimToDefault(string string_0, string defaultString)
		{
			if (string_0 != null && (string_0 = string_0.Trim()).get_Length() != 0)
			{
				return string_0;
			}
			return defaultString;
		}
		public ApplicationBar GetApplicationBar()
		{
			return null;
		}
		private void txtMMNameClick(object sender, RoutedEventArgs e)
		{
			base.GoToPage("/Source/UI/Setting/ModifyAliasPage.xaml", null, false);
		}
		private void txtQQNum_Click(object sender, RoutedEventArgs e)
		{
			if (AccountMgr.nBindQQ > 0u)
			{
				string text = "setting";
				base.GoToPage("/Source/UI/Setting/BindedQQPage.xaml", new object[]
				{
					text
				}, false);
				return;
			}
			string text2 = "findFriend";
			base.GoToPage("/Source/UI/QQFriends/GoBindQQ.xaml", new object[]
			{
				text2
			}, false);
		}
		private void txtPhoneNum_Click(object sender, RoutedEventArgs e)
		{
			if (ToolFunction.checkIsPhoneNumber(AccountMgr.strBindMobile) && AccountMgr.MobileVerify)
			{
				base.GoToPage("/Source/UI/Setting/BindedMobilePage.xaml", null, false);
				return;
			}
			base.GoToPage("/Source/UI/PhoneContact/PhoneNumBinding.xaml", null, false);
		}
		private void txtEmail_Click(object sender, RoutedEventArgs e)
		{
			base.GoToPage("/Source/UI/Setting/BindEmailPage.xaml", null, false);
		}
		private string GetFaceBookName()
		{
			Account curAccount = AccountMgr.getCurAccount();
			if (curAccount == null)
			{
				return null;
			}
			if (string.IsNullOrEmpty(curAccount.FBUserName))
			{
				return null;
			}
			return curAccount.FBUserName;
		}
		private void txtFaceBook_Click(object sender, RoutedEventArgs e)
		{
			PhoneApplicationFrame phoneApplicationFrame = Application.get_Current().get_RootVisual() as PhoneApplicationFrame;
			BasePage basePage = phoneApplicationFrame.get_Content() as BasePage;
			if (basePage == null)
			{
				return;
			}
			Account curAccount = AccountMgr.getCurAccount();
			if (curAccount == null)
			{
				return;
			}
			if (curAccount.FaceBookFlag <= 0u)
			{
				FaceBookBind.ShowBindPage(basePage, false);
				return;
			}
			UnbindFaceBook.ShowUnbindFaceBookPage(this, curAccount.FBToken);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Setting/AccountSettingView.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.ContentPanel = (Grid)base.FindName("ContentPanel");
			this.layoutAlias = (StackPanel)base.FindName("layoutAlias");
			this.txtAlias = (TextBlock)base.FindName("txtAlias");
			this.layoutMMName = (ClickableLayout)base.FindName("layoutMMName");
			this.txtMMName = (TextBlock)base.FindName("txtMMName");
			this.txtQQNum = (TextBlock)base.FindName("txtQQNum");
			this.txtPhoneNum = (TextBlock)base.FindName("txtPhoneNum");
			this.txtEmail = (TextBlock)base.FindName("txtEmail");
			this.FaceBookArea = (ClickableLayout)base.FindName("FaceBookArea");
			this.txtFaceBook = (TextBlock)base.FindName("txtFaceBook");
		}
	}
}
